package com.lp.aop.jdk;

import com.lp.aop.Animal;
import com.lp.aop.Cat;

/**
 * @author: lp
 * @create: 2024-03-06 7:56
 * @description: JDK动态代理
 */
public class Test {
	public static void main(String[] args) {
		//1.创建目标对象
		Cat cat = new Cat();
		cat.eat();


		System.out.println("----------------------------");
		//2.创建代理对象
		JdkDynamicProxy jdkDynamicProxy = new JdkDynamicProxy(cat);

		//3.获取代理对象,调用代理对象方法
		Animal animal = (Animal) jdkDynamicProxy.getProxy();//此处只能强转成cat的接口，代理对象只实现接口
		animal.eat();

	}
}
